package com.sitech.portal.bigScreen.action;

import com.sitech.ibnms.core.JGridBaseAction;
import com.sitech.portal.bigScreen.domain.ScreenLogicalPanel;
import com.sitech.portal.bigScreen.form.ScreenLogicalPanelForm;
import com.sitech.portal.bigScreen.form.TbScreenLogicalForm;
import com.sitech.portal.bigScreen.service.IScreenLogicalService;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2015/4/22.
 */
public class ScreenLogicalAction extends JGridBaseAction {
    private IScreenLogicalService screenLogicalService;
    private TbScreenLogicalForm form=new TbScreenLogicalForm();
    private String physicalScreenId;
    List<ScreenLogicalPanelForm> panels=new ArrayList<ScreenLogicalPanelForm>();
    Map<String,Object> forms=null;
    Map<String,Object> formVO=new HashMap<String, Object>();
    List<String> physicalScreenNames;

    private boolean ifExist=false;

    public String queryList(){
        setResult(screenLogicalService.queryScreenLogicalByFilter(physicalScreenId,form,this.getPageForm()));
        return SUCCESS;
    }

    public String queryByPhysicalScreenId(){
        forms=new HashMap<String, Object>();
        forms.put("rows",screenLogicalService.queryByPhysicalScreenId(physicalScreenId));
        return SUCCESS;
    }

    public String queryById(){
        formVO=screenLogicalService.queryLogicalScreenById(form.getLogicalScreenId());
        return SUCCESS;
    }

    public String  addScreenLogical(){
        screenLogicalService.addOrUpdateScreenLogical(form,panels);
        return SUCCESS;
    }

    public String delete(){
        screenLogicalService.deleteScreenLogicalById(form.getLogicalScreenId());
        return SUCCESS;
    }

    public String ifNameExist(){
        ifExist=screenLogicalService.ifNameExist(form);
        return SUCCESS;
    }

    public String validateLogicalScreenDelete(){
        physicalScreenNames=screenLogicalService.queryPhysicalScreenByLogicalScreenId(form.getLogicalScreenId());
        return SUCCESS;
    }

    public String redirect(){
        return SUCCESS;
    }

    /**get和set方法*/
    public void setScreenLogicalService(IScreenLogicalService screenLogicalService) {
        this.screenLogicalService = screenLogicalService;
    }

    public TbScreenLogicalForm getForm() {
        return form;
    }

    public void setForm(TbScreenLogicalForm form) {
        this.form = form;
    }

    public void setPhysicalScreenId(String physicalScreenId) {
        this.physicalScreenId = physicalScreenId;
    }

    public String getPhysicalScreenId() {
        return physicalScreenId;
    }

    public List<ScreenLogicalPanelForm> getPanels() {
        return panels;
    }

    public void setPanels(List<ScreenLogicalPanelForm> panels) {
        this.panels = panels;
    }

    public Map<String, Object> getFormVO() {
        return formVO;
    }

    public void setFormVO(Map<String, Object> formVO) {
        this.formVO = formVO;
    }

    public boolean isIfExist() {
        return ifExist;
    }

    public Map<String, Object> getForms() {
        return forms;
    }

    public void setForms(Map<String, Object> forms) {
        this.forms = forms;
    }

    public List<String> getPhysicalScreenNames() {
        return physicalScreenNames;
    }
}
